package com.hkrt.demo.demo1.dao;

import com.hkrt.demo.demo1.entity.User;

import java.util.List;

/**
 * Created by admin on 2019/12/5.
 */
public class Dao extends BaseDao {

   public int update(User user){
       String sql= "update user set username=?,password=?,age=? where id=?";
       Object[] parms = {user.getUsername(),user.getPassword(),user.getAge(),user.getUserid()};
       int rows = super.update(sql, parms);
       return rows;
   }

    public int insert(User user){
        String sql= "insert into user (userid,username,passwrod,age) values(?,?,?,?)";
        Object[] parms = {user.getUserid(),user.getUsername(),user.getPassword(),user.getAge()};
        int rows = super.update(sql, parms);
        return rows;
    }

    public int delete(User user){
        String sql= "delete from user where userid=?";
        Object[] parms = {user.getUsername(),user.getPassword(),user.getAge(),user.getUserid()};
        int rows = super.update(sql, parms);
        return rows;
    }

    public List<User> select(User user){
        String sql= "select userid,username,password,age from user where userid = ?";
        Object[] params = {user.getUserid()};
        List<User> userList = super.query(sql, User.class, params);
        return userList;

    }
}
